package name.marz.to.go.ahg.SMBCVisa.executer;

import name.marz.to.go.ahg.core.checker.DocumentChecker;
import name.marz.to.go.ahg.core.exception.CannotLoginException;
import name.marz.to.go.ahg.core.exception.UserProcessException;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class SMBCVisaLoginChecker implements DocumentChecker {
	@Override
	public void check(Document doc) throws UserProcessException {
		if ( doc.getElementById("myPage") != null ) return;
		Elements elems = doc.getElementsByClass("s3");
		if ( elems.size() == 0 ) throw new CannotLoginException("** could not find messeges **");
		StringBuffer sb = new StringBuffer();
		for (Element e : elems) {
			sb.append(e.text()).append(" ");
		}
		throw new CannotLoginException(sb.toString());
	}
}